﻿/***************************
* 1.支付结果
****************************/

/* 变量 */
var payResult = "booking/payResult.html";
var orderSuccess = "elements/orderSuccess.html";

/* 付款结果  */
var contactsCallback_payResult = myApp.onPageInit('payResult', function (page) {

    try {
        var type = ISS.utils.getParameter("type");
        var result = ISS.utils.getParameter("result");
        if (page != undefined) {
            type = page.query.type;
            result = page.query.result;
        }

        //类型: 1:景区,2:酒店,3：线路,22:团购
        if (type == "1") {
            $$("#payResult_page .list").on("click",function(){
                mainView.router.loadPage({url:"../../view/booking/ticket.html",reload:true});
            })
            $$("#payResult_page .order").on("click",function(){
                mainView.router.loadPage({url:"../../view/user/panicBuyingOrderList.html",reload:true});
            })
        }
        else if (type == "2") {
            $$("#payResult_page .list").on("click",function(){
                mainView.router.loadPage({url:"../../view/booking/hotel.html",reload:true});
            })
            $$("#payResult_page .order").on("click",function(){
                mainView.router.loadPage({url:"../../view/user/orderList.html?orderType=" + type,reload:true});
            })
        }
        else if (type == "3") {
            $$("#payResult_page .list").on("click",function(){
                mainView.router.loadPage({url:"../../view/booking/line.html",reload:true});
            })
            $$("#payResult_page .order").on("click",function(){
                mainView.router.loadPage({url:"../../view/user/orderList.html?orderType=" + type,reload:true});
            })
        }
        else if (type == "22") {
             $$("#payResult_page .list").on("click",function(){
                mainView.router.loadPage({url:"../../view/booking/group.html",reload:true});
            })
            $$("#payResult_page .order").on("click",function(){
                mainView.router.loadPage({url:"../../view/user/orderList.html?orderType=" + type,reload:true});
            })
        }

        if (result == "true") {
            $$("#payResult_page #success").show();
            $$("#payResult_page #faild").hide();
        }
        else {
            $$("#payResult_page #faild").show();
            $$("#payResult_page #success").hide();
        }
    } catch (e) {

    }

});

var contactsCallback_orderSuccess = myApp.onPageInit('orderSuccess', function (page) {
    var sumprice = page.query.sumprice;
    var ticketName = page.query.ticketName;
    var playDate = page.query.playDate;
    var ticketNumber = page.query.ticketNumber;
    var salePrice = page.query.salePrice;
    var orderNo = page.query.OrderNo;
    var ticketNo = page.query.tcode;
    var shopNo = page.query.sCode;
    var shopName = page.query.shopName;

    $$(".orderSuccess .sumprice").html("¥" + sumprice);
    $$(".orderSuccess .ticketName").html(ticketName);
    $$(".orderSuccess .playDate").html(playDate);
    $$(".orderSuccess .orderNumber").html(ticketNumber);
    iss_localStorage.set("yuqing_isfresh","true");
    $$(".orderSuccess .refund").on("click", function () {
        mainView.router.loadPage({ url: '../../view-yuqing/elements/ticketRefund.html?OrderNo=' + orderNo + "&OrderType=1&OrderName=" + ticketName +"&salePrice="+salePrice+"&success=true", reload: true });
    })

    $$(".orderSuccess .buy").on("click", function () {
        iss_localStorage.set("yuqing_visitorList", "-1");
        mainView.router.loadPage({ url: "../../view/booking/ticketBooking_ysp.html?tcode=" + ticketNo + "&sCode=" + shopNo + "&sName=" + ticketName + "&shopName=" + shopName, reload: false });
    })
});

/* 初始化  */
function initData() {
    var href = window.location.href;
    if (href.indexOf(payResult) > -1) {
        contactsCallback_payResult.trigger();
    } else if (href.indexOf(orderSuccess) > -1) {
        contactsCallback_orderSuccess.trigger();
    }
}

initData();

